/**
 * Created by jianhuang on 2014/12/29.
 */
var shareFlag = 1;
//吊起客户端分享
var shareRead_link = encodeURIComponent("http://3g.k.sohu.com/active/71/landspace.html");
var shareRead_pics = encodeURIComponent("http://3g.k.sohu.com/active/71/images/weixin_icon.jpg");
var shareRead_title = encodeURIComponent("玩进攻的狐狸，天天领滴滴红包！速带基友一起来！");
var shareRead_content = encodeURIComponent("玩进攻的狐狸，天天领滴滴红包！速带基友一起来！");
var shareRead_sourceType = 42;
var _protocolLink = "share://";
var ShareTools = {
    shareThisPage: function() {
        // 创建一个iframe丢到页面中，加载某条链接
        function loadIframe(url) {

            var timer = null;

            var iframe = document.createElement('iframe');
            iframe.style.display = 'none';

            iframe.src = url;

            var callback = function() {

                if (iframe && iframe.readyState && iframe.readyState != "loaded" && iframe.readyState != "complete") {
                    return;
                }
                // 清理iframe标签
                iframe.onload = iframe.onreadystatechange = iframe.onerror = null;
                iframe.src = "";
                iframe.parentNode.removeChild(iframe);
                iframe = null;

                if (timer) {
                    clearTimeout(timer);
                    timer = null;
                }
            };

            iframe.onload = iframe.onerror = iframe.onreadystatechange = callback;
            document.getElementsByTagName("body")[0].appendChild(iframe);
            if (typeof alertDom !== 'undefined') {
                alertDom.remove();
                alertDom = null;
            }

            timer = setTimeout(function() {
                callback();
            }, 40);
        }

        //分享按钮只在客户端内部展示
        var ua = navigator.userAgent.toLowerCase();
        if (shareFlag==0) {
            shareRead_title = encodeURIComponent("朋友圈都转疯了，玩得根本停不下来！");
            shareRead_content = encodeURIComponent("玩进攻的狐狸，天天领滴滴红包！速带基友一起来！");
        };
        if (/sohunews/.test(ua)) {
            var _str = "link=" + shareRead_link + "&pics=" + shareRead_pics + "&title=" + shareRead_title + "&content=" + shareRead_content + "&sourceType=" + shareRead_sourceType;
            var _tmpOpenLink = _protocolLink + _str;
            loadIframe(_tmpOpenLink);
        } else if (/micromessenger/.test(ua)) {
            $(".filter").show();
        }
        $(".succTip").hide();
        $(".mask").hide();
    }
};

// 统计数据
var tjObjExtend = {
    u:"lp",
    contentType:"active",
    activeid: 71,
    objType:"h5_active_71_1"
};
